//
//  IGameState.h
//  Monster_Martial_Arts_Version_0
//
//  Created by chiawei.tseng on 13/1/4.
//
//

#ifndef Monster_Martial_Arts_Version_0_GameState_h
#define Monster_Martial_Arts_Version_0_GameState_h

#include <map>

using namespace std;

enum STATE_ID
{
    INVALID_STATE_ID = -1,
};

class IStateInput
{
public:
    
    virtual ~IStateInput(){}
};

//class BaseFiniteStateMachine;
class IBaseState
{
public:
    
    virtual void Entering(IStateInput*)=0;
    
    virtual void Update(IStateInput*)=0;
    
    virtual void Leaving(IStateInput*)=0;
    
    virtual int ShouldChange(IStateInput*) = 0;
    
    virtual ~IBaseState(){}
};

class BaseFiniteStateMachine
{
public:
    
        
    BaseFiniteStateMachine();
    
    virtual ~BaseFiniteStateMachine(){}
    
    virtual void Update(IStateInput*)=0;
    
    virtual void SetInitialState(int stateID);
    
    virtual void JumpToState(const int nextSateID , IStateInput*)=0;
    
    int  GetCurrentStateID(){return m_CurrentStateID;}
    
    void AddState(int StatID , IBaseState*);
    
    void RemoveAll();
    
protected:
    
    int m_CurrentStateID;
    int m_NextCurrentStateID;
    int m_PreCurrentStateID;
        
    map<int,IBaseState*> m_mapState;
    
};


#endif
